namespace SimpleWebServices.Globalization
{
    using System;
    using System.Globalization;
    using System.Threading;
    using SimpleWebServices;
    using Xunit;

    public sealed class CultureInfoExtensionMethodsFacts
    {
        [Fact]
        public void typedef()
        {
            Assert.True(typeof(CultureInfoExtensionMethods).IsStatic());
        }

        [Fact]
        public void op_SetCurrentCulture_CultureInfo()
        {
            CultureInfo culture = Thread.CurrentThread.CurrentUICulture;

            try
            {
                CultureInfo expected = new CultureInfo("fr");

                expected.SetCurrentCulture();

                CultureInfo actual = Thread.CurrentThread.CurrentUICulture;

                Assert.Equal<CultureInfo>(expected, actual);
            }
            finally
            {
                Thread.CurrentThread.CurrentUICulture = culture;
            }
        }

        [Fact]
        public void op_SetCurrentCulture_CultureInfoNull()
        {
            Assert.Throws<ArgumentNullException>(() => (null as CultureInfo).SetCurrentCulture());
        }

        [Fact]
        public void op_SetCurrentCulture_CultureInfoInvariantCulture()
        {
            Assert.Throws<ArgumentOutOfRangeException>(() => CultureInfo.InvariantCulture.SetCurrentCulture());
        }
    }
}